#include "scoreSort.h"
using namespace std;
using namespace li;
const int MAXCNT = 1000;
 
//comparator1
bool  CmpBys1(const Stu*  ps1,  const Stu* ps2)
{
    return ps1->getS1() > ps2->getS2();
}
 
//comparator2
bool CmpBysum(const Stu*   ps1, const Stu*  ps2)
{
    return ps1->getSum() > ps2->getSum();
}
 
//comparator3
bool CmpBysum_name( const Stu*  ps1, const Stu*   ps2)
{
    if(ps1->getSum() > ps2->getSum())
        return true;
    if( ps1->getSum() < ps2->getSum())
        return false;
    return ps1->getName() < ps2->getName();
}
 
int main()
{
    Stu* stuPtrs[MAXCNT];
    cout << "Load Data From: " << filename  <<"...\n"<< endl;
 
    int cnt = ReadStuList(filename,stuPtrs);
    DispStuList(stuPtrs,cnt);
 
 
    cout << "Sort by score1(dec)"<<endl;
    StuSort(stuPtrs,cnt,CmpBys1);
    DispStuList(stuPtrs,cnt);
 
    cout << "Sort by sum(dec)"<<endl;
    StuSort(stuPtrs,cnt,CmpBysum);
    DispStuList(stuPtrs,cnt);
 
    cout << "Sort by sum(dec)&name(asc)"<<endl;
    StuSort(stuPtrs,cnt,CmpBysum_name);
    DispStuList(stuPtrs,cnt);
 
    for(int i=0; i<cnt; i++)
        delete stuPtrs[i];
 
     return 0;
}

